using AutoMapper;
using Pay.DTO;
using Pay.Data;
using Pay.IService;

namespace Pay.Service.AutoMapper
{
    public class ActivityMapper : IStartupDto
    {
        private IMapperConfigurationExpression _cfg;
        public ActivityMapper(IMapperConfigurationExpression cfg)
        {
            _cfg = cfg;
        }
        public void Execute()
        {
            Create();
        }
        protected virtual void Create()
        {
            _cfg.CreateMap<Activity, activity_dto>()
                .ForMember(dest => dest.id, src => src.MapFrom(c => c.Id))
                .ForMember(dest => dest.type, src => src.MapFrom(c => c.Type))
                .ForMember(dest => dest.title, src => src.MapFrom(c => c.Title))
                .ForMember(dest => dest.img_url, src => src.MapFrom(c => c.ImgUrl))
                .ForMember(dest => dest.link_url, src => src.MapFrom(c => c.LinkUrl))
                .ForMember(dest => dest.detail, src => src.MapFrom(c => c.Detail))
                .ForMember(dest => dest.begin_time, src => src.MapFrom(c => c.BeginTime))
                .ForMember(dest => dest.end_time, src => src.MapFrom(c => c.EndTime))
                .ForMember(dest => dest.click_num, src => src.MapFrom(c => c.ClickNum))
                .ForMember(dest => dest.participation_num, src => src.MapFrom(c => c.ParticipationNum))
                .ForMember(dest => dest.status, src => src.MapFrom(c => c.Status))
                .ForMember(dest => dest.preheat_time, src => src.MapFrom(c => c.PreheatTime))
                .ForMember(dest => dest.is_index_show, src => src.MapFrom(c => c.IsIndexShow));




            _cfg.CreateMap<activity_dto, Activity>()
                .ForMember(dest => dest.Id, src => src.MapFrom(c => c.id))
                .ForMember(dest => dest.Type, src => src.MapFrom(c => c.type))
                .ForMember(dest => dest.Title, src => src.MapFrom(c => c.title))
                .ForMember(dest => dest.ImgUrl, src => src.MapFrom(c => c.img_url))
                .ForMember(dest => dest.LinkUrl, src => src.MapFrom(c => c.link_url))
                .ForMember(dest => dest.Detail, src => src.MapFrom(c => c.detail))
                .ForMember(dest => dest.BeginTime, src => src.MapFrom(c => c.begin_time))
                .ForMember(dest => dest.EndTime, src => src.MapFrom(c => c.end_time))
                .ForMember(dest => dest.ClickNum, src => src.MapFrom(c => c.click_num))
                .ForMember(dest => dest.ParticipationNum, src => src.MapFrom(c => c.participation_num))
                .ForMember(dest => dest.Status, src => src.MapFrom(c => c.status))
                .ForMember(dest => dest.PreheatTime, src => src.MapFrom(c => c.preheat_time))
                .ForMember(dest => dest.IsIndexShow, src => src.MapFrom(c => c.is_index_show));




        }
    }
}
